<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 管理系统大布局 - Layui</title>
    <link rel="stylesheet" href="./lib/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">layui 管理布局</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="javascript:;">控制台</a></li>
            <li class="layui-nav-item"><a href="javascript:;">商品管理</a></li>
            <li class="layui-nav-item"><a href="javascript:;">用户</a></li>
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;">邮件管理</a></dd>
                    <dd><a href="javascript:;">消息管理</a></dd>
                    <dd><a href="javascript:;">授权管理</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    贤心
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="javascript:;">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test" lay-shrink="all">
                <li class="layui-nav-item"><a href="javascript:;" target-page="/page/consoleConfig.html">标段操作台按钮(旧版)</a>
                </li>
                <li class="layui-nav-item"><a href="javascript:;" target-page="/page/bidStatus.html">标段状态管理</a></li>
                <li class="layui-nav-item">
                    <a class="" href="javascript:;">赢标2.0后台管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" target-page="/page/apiAuth.html">接口权限管理(v2.1.02)</a></dd>
                        <dd><a href="javascript:;" target-page="/page/consoleButton.html">标段操作台按钮(v2.1.01)</a></dd>
                        <dd><a href="javascript:;" target-page="/page/roleAuth.html">角色权限维护(v2.1.02)</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">手机端扫码Demo</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" target-page="/page/scan/login.html">登录</a></dd>
                        <dd><a href="javascript:;" target-page="/page/scan/sign.html">签章</a></dd>
                        <dd><a href="javascript:;" target-page="/page/scan/encrypt.html">加密</a></dd>
                        <dd><a href="javascript:;" target-page="/page/scan/decrypt.html">解密</a></dd>
                        <dd><a href="javascript:;" target-page="/page/scan/validate.html">验证</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="" href="javascript:;">工作流测试</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" target-page="/page/flow/usersPage.html">用户管理</a></dd>
                        <dd><a href="javascript:;" target-page="/page/flow/rolesPage.html">角色管理</a></dd>
                        <dd><a href="javascript:;" target-page="/page/flow/flowList.html">流程模板设计</a></dd>
                        <dd><a href="javascript:;" target-page="/page/flow/formList.html">表单管理</a></dd>
                        <dd><a href="javascript:;" target-page="/page/flow/todoList.html">待办事项</a></dd>
                        <dd><a href="javascript:;" target-page="/page/flow/instanceManage.html">流程实例管理</a></dd>
                        <dd><a href="javascript:;" target-page="/page/flow/auditHistoryList.html">审批历史</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="javascript:;" target-page="/page/test.html">页面测试</a></li>
                <li class="layui-nav-item"><a href="javascript:;" target-page="/page/testWebsocket.html" ws="1">websocket测试</a></li>
                <li class="layui-nav-item"><a href="javascript:;" target-page="/page/testWebsocketOld.html" ws="1">websocket测试(旧)</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div id="contentHtml" style="padding: 15px;">内容主体区域</div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域 <span id="heartCheckContent"></span>
    </div>
</div>
<script src="./lib/layui/layui.js" type="text/javascript"></script>
<script src="./js/lay-config.js" type="text/javascript"></script>
<script src="./js/websocket.common.js" charset="utf-8"></script>
<script>
    var currentPage = null;
    var websocketLock = null;
    globalTradeRemoteUrl = "http://local.fzznkj.com:8106";

    function jumpPage(targetPage) {
        $.get(rootPath + targetPage, function (content) {
            $("#contentHtml").html(content);
            currentPage = targetPage;
        });
    }

    //JavaScript代码区域
    layui.use(['element', 'request', 'api'], function () {
        let element = layui.element;

        $ = layui.$;
        request = layui.request;
        api = layui.api;

        element.on('nav(test)', function (elem) {
            let outerHTML = elem[0]['outerHTML'];
            if (!outerHTML) {
                return;
            }
            let $outerHTML = $(outerHTML);
            let targetPage = $outerHTML.attr('target-page');
            let wsLock = $outerHTML.attr('ws');
            if (targetPage && targetPage !== currentPage) {
                jumpPage(targetPage);

                currentPage = targetPage;
                websocketLock = wsLock;

                // 断开websocket连接
                if (socket && !websocketLock) {
                    socket.close();
                }
            }
        });
    });
</script>
</body>
</html>
